<!--#include file="classData.asp"-->
<%
Response.Buffer = True 
Response.ExpiresAbsolute = Now() - 1 
Response.Expires = 0 
Response.CacheControl = "no-cache" 
Response.AddHeader "Pragma", "No-Cache"


	set HuaObj = new sysData
	HuaObj.sqlConnOpen()

	set SystemRds=server.CreateObject("ADODB.recordset")
	HuaObj.DbQuery SystemRds,"sysVar",QueryStr,0," VarId = 1"
	
	CurrentSeason = SystemRds("CurrentSeason")

	SystemRds.Close


	HuaObj.p_DbConnection.BeginTrans
	on error resume next


	InsertSql = "TRUNCATE TABLE CheckLA"
	HuaObj.SCommand(InsertSql)
	
	InsertSql = "TRUNCATE TABLE CheckLB"
	HuaObj.SCommand(InsertSql)
	

	InsertSql = "INSERT INTO CheckLA SELECT ManagerId,SeasonNum,AreaLevel,0,0,0,0,TotalRound,0,0,0,0 FROM AreaLeague WHERE SeasonNum = "&CurrentSeason
	HuaObj.SCommand(InsertSql)

	'*********主场胜***************
	InsertSql = "INSERT INTO CheckLA SELECT HomeId,0,0,3,HomeScore,AwayScore,(HomeScore - AwayScore),0,1,0,0,1 FROM LeaguePlan WHERE SeasonNum = "&CurrentSeason&" AND IfDone = 2 AND HomeScore > AwayScore"
	HuaObj.SCommand(InsertSql)	
	
	'*********主场负***************
	InsertSql = "INSERT INTO CheckLA SELECT HomeId,0,0,0,HomeScore,AwayScore,(HomeScore - AwayScore),0,0,1,0,1 FROM LeaguePlan WHERE SeasonNum = "&CurrentSeason&" AND IfDone = 2 AND HomeScore < AwayScore"
	HuaObj.SCommand(InsertSql)	

	'*********主场平***************
	InsertSql = "INSERT INTO CheckLA SELECT HomeId,0,0,1,HomeScore,AwayScore,0,0,0,0,1,1 FROM LeaguePlan WHERE SeasonNum = "&CurrentSeason&" AND IfDone = 2 AND HomeScore = AwayScore"
	HuaObj.SCommand(InsertSql)	

	'*********客场胜***************
	InsertSql = "INSERT INTO CheckLA SELECT AwayId,0,0,3,AwayScore,HomeScore,(AwayScore - HomeScore),0,1,0,0,1 FROM LeaguePlan WHERE SeasonNum = "&CurrentSeason&" AND IfDone = 2 AND AwayScore > HomeScore"
	HuaObj.SCommand(InsertSql)	
	
	'*********客场负***************
	InsertSql = "INSERT INTO CheckLA SELECT AwayId,0,0,0,AwayScore,HomeScore,(AwayScore - HomeScore),0,0,1,0,1 FROM LeaguePlan WHERE SeasonNum = "&CurrentSeason&" AND IfDone = 2 AND AwayScore < HomeScore"
	HuaObj.SCommand(InsertSql)	

	'*********客场平***************
	InsertSql = "INSERT INTO CheckLA SELECT AwayId,0,0,1,AwayScore,HomeScore,0,0,0,0,1,1 FROM LeaguePlan WHERE SeasonNum = "&CurrentSeason&" AND IfDone = 2 AND AwayScore = HomeScore"
	HuaObj.SCommand(InsertSql)	


	InsertSql = "INSERT INTO CheckLB SELECT ManagerId,Max(SeasonNum),Max(AreaLevel),SUM(Score),SUM(Goal),SUM(Fumble),SUM(GoalDif),SUM(TotalRound),SUM(WinNum),SUM(LostNum),SUM(DrawNum),SUM(RealRound) FROM CheckLA GROUP BY ManagerId"
	HuaObj.SCommand(InsertSql)	
	
	InsertSql = "DELETE FROM CheckLB WHERE TotalRound = RealRound"
	HuaObj.SCommand(InsertSql)	


	response.ContentType="text/xml"	
	Response.Write("<?xml version=""1.0"" encoding=""gb2312""?>"&vbcrlf)
	Response.Write("<xml>"&vbcrlf)


	if err.number =0 then  
    	HuaObj.p_DbConnection.CommitTrans  '如果没有conn错误，则执行事务提交
		Response.Write("<Shi ShiId = ""1"">"&vbcrlf)
		Response.Write("</Shi>"&vbcrlf)
	else 
    	HuaObj.p_DbConnection.RollbackTrans '否则回滚
		Response.Write("<Shi ShiId = ""0"">"&vbcrlf)
		Response.Write("</Shi>"&vbcrlf)
	end if

	Response.Write("</xml>"&vbcrlf)

	
	HuaObj.sqlConnClose()


%>
